package com.foreknow.demo10;

public class ExceptionDemo3 {
    public int add(int a,int b) throws Exception {
        if(a < 0 || b < 0) {
          Exception e = new Exception();
          throw e; //人为制造异常(需要自己new异常类的对象)
        }
        return a + b;
    }

    public static void main(String[] args) throws Exception {
        ExceptionDemo3 demo3 = new ExceptionDemo3();
        demo3.add(-1,-2);
    }
}
